package com.xbongbong.saas.help;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.xbongbong.i18n.util.I18nMessageUtil;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.constant.TimeConstant;
import com.xbongbong.paas.enums.ConditionEnum;
import com.xbongbong.paas.enums.FieldTypeEnum;
import com.xbongbong.paas.enums.StarEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.field.ItemPoJo;
import com.xbongbong.paas.help.FormDataListSearchHelp;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.applist.pojo.SelectOptionPojo;
import com.xbongbong.pro.constant.CommonConstant;
import com.xbongbong.pro.constant.I18nStringConstant;
import com.xbongbong.pro.constant.RangeScreenConstant;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.constant.StringConstant;
import com.xbongbong.saas.domain.entity.WorkOrderStageEntity;
import com.xbongbong.saas.domain.entity.WorkOrderTemplateEntity;
import com.xbongbong.saas.enums.BirthdayFilterEnum;
import com.xbongbong.saas.enums.ListGroupEnum;
import com.xbongbong.saas.enums.PayBalanceEnum;
import com.xbongbong.saas.enums.SelectProductEnum;
import com.xbongbong.saas.enums.WorkOrderNodeStatusEnum;
import com.xbongbong.saas.enums.business.AssembleEnum;
import com.xbongbong.saas.enums.business.BomBillEnum;
import com.xbongbong.saas.enums.business.ClueEnum;
import com.xbongbong.saas.enums.business.ContactEnum;
import com.xbongbong.saas.enums.business.ContractEnum;
import com.xbongbong.saas.enums.business.CustomerCommunicateEnum;
import com.xbongbong.saas.enums.business.CustomerManagementEnum;
import com.xbongbong.saas.enums.business.DistributorAccountEnum;
import com.xbongbong.saas.enums.business.ExpenseEnum;
import com.xbongbong.saas.enums.business.FundTransferEnum;
import com.xbongbong.saas.enums.business.InstockEnum;
import com.xbongbong.saas.enums.business.InventoryEnum;
import com.xbongbong.saas.enums.business.InvoiceEnum;
import com.xbongbong.saas.enums.business.KnowledgeDataEnum;
import com.xbongbong.saas.enums.business.OtherExpenseEnum;
import com.xbongbong.saas.enums.business.OtherIncomeEnum;
import com.xbongbong.saas.enums.business.OutstockEnum;
import com.xbongbong.saas.enums.business.PayPlanEnum;
import com.xbongbong.saas.enums.business.PaySheetEnum;
import com.xbongbong.saas.enums.business.PaymentBalanceEnum;
import com.xbongbong.saas.enums.business.PaymentEnum;
import com.xbongbong.saas.enums.business.PaymentSheetEnum;
import com.xbongbong.saas.enums.business.ProductEnum;
import com.xbongbong.saas.enums.business.ProductionOrderEnum;
import com.xbongbong.saas.enums.business.PurchaseEnum;
import com.xbongbong.saas.enums.business.PurchaseInvoiceEnum;
import com.xbongbong.saas.enums.business.QuotationEnum;
import com.xbongbong.saas.enums.business.ReimbursementFormEnum;
import com.xbongbong.saas.enums.business.ReturnedPurchaseEnum;
import com.xbongbong.saas.enums.business.SalesOpportunityEnum;
import com.xbongbong.saas.enums.business.SupplierCommunicateEnum;
import com.xbongbong.saas.enums.business.SupplierContactEnum;
import com.xbongbong.saas.enums.business.SupplierEnum;
import com.xbongbong.saas.enums.business.TransferEnum;
import com.xbongbong.saas.enums.business.WarehouseEnum;
import com.xbongbong.saas.enums.business.WorkOrderEnum;
import com.xbongbong.saas.enums.business.WorkReportFieldEnum;
import com.xbongbong.saas.enums.dictionary.PublicEnum;
import com.xbongbong.saas.service.WorkOrderTemplateService;
import com.xbongbong.workorder.service.WorkOrderStageService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;


/**
 * @author long.rao
 * @version v1.0
 * @date 2019/3/14 11:14
 * @since v1.0
 */
@Component
public class SearchFilterHelp {

    @Resource
    private WorkOrderTemplateService workOrderTemplateService;
    @Resource
    private WorkOrderStageService workOrderStageService;
    @Resource
    private FormDataListSearchHelp formDataListSearchHelp;

    /**
     * 工作报告默认排序字段
     *
     * @param
     * @author GuoJun.HU
     * @since V1.0
     * @return JSONArray
     * @date 2019/4/3 15:11
     */
    public List<SelectOptionPojo> getWorkReportOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, CustomerCommunicateEnum.COMMUNICATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WorkReportFieldEnum.REPORT_DATE.getAttr()),
                    explainMap.get(WorkReportFieldEnum.REPORT_DATE.getAttr()).getAttrName(), WorkReportFieldEnum.REPORT_DATE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 合同排序
     * @author long.rao
     * @date 2019-03-20 13:44
     */
    public List<SelectOptionPojo> getContractOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ContractEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(ContractEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(ContractEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), ContractEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, ContractEnum.AMOUNT.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(ContractEnum.AMOUNT.getAttr());
            attrEntity = explainMap.get(ContractEnum.AMOUNT.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, attrEntity.getAttrName(), ContractEnum.AMOUNT.getAttr()));
        }
        if (fieldEnable(explainMap, ContractEnum.SIGN_TIME.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(ContractEnum.SIGN_TIME.getAttr());
            attrEntity = explainMap.get(ContractEnum.SIGN_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, attrEntity.getAttrName(), ContractEnum.SIGN_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 报价单排序
     * @author long.rao
     * @date 2019-03-20 13:44
     */
    public List<SelectOptionPojo> getQuotationOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, QuotationEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(QuotationEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, I18nMessageUtil.getMessage(CommonConstant.ADD_TIME), QuotationEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, QuotationEnum.AMOUNT.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(QuotationEnum.AMOUNT.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, QuotationEnum.AMOUNT.getAttrName(), QuotationEnum.AMOUNT.getAttr()));
        }
        if (fieldEnable(explainMap, QuotationEnum.QUOTATION_TIME.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(QuotationEnum.QUOTATION_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, QuotationEnum.QUOTATION_TIME.getAttrName(), QuotationEnum.QUOTATION_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 客户排序
     * @author long.rao
     * @date 2019-03-20 13:44
     */
    public List<SelectOptionPojo> getCustomerOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, CustomerManagementEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(CustomerManagementEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, explainMap.get(CustomerManagementEnum.ADD_TIME.getAttr()).getAttrName(), CustomerManagementEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, CustomerManagementEnum.UPDATE_TIME.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(CustomerManagementEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, explainMap.get(CustomerManagementEnum.UPDATE_TIME.getAttr()).getAttrName(), CustomerManagementEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, CustomerManagementEnum.LAST_CONNECT_TIME.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(CustomerManagementEnum.LAST_CONNECT_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, explainMap.get(CustomerManagementEnum.LAST_CONNECT_TIME.getAttr()).getAttrName(), CustomerManagementEnum.LAST_CONNECT_TIME.getAttr()));
        }
        // TODO 客户距离排序
        //selectOptionPojoList.add(new SelectOptionPojo("4", "距离", null));
        return selectOptionPojoList;
    }

    /**
     * 附近客户特殊筛选（公海，非公海）
     * @author long.rao
     * @date 2019-04-23 19:37
     */
    public JSONArray getCustomerSpecialFilter() {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(0), I18nMessageUtil.getMessage(CommonConstant.SIMPLE_CUSTOMER), 1,
                FieldTypeEnum.NUM.getType(), 0, CustomerManagementEnum.IS_PUBLIC.getAttr(), null, ConditionEnum.EQUAL.getSymbol()));
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(1), PublicEnum.PUBLIC.getName(), 1,
                FieldTypeEnum.NUM.getType(), 0, CustomerManagementEnum.IS_PUBLIC.getAttr(), null, ConditionEnum.EQUAL.getSymbol()));
        return JSON.parseArray(JSON.toJSONString(selectOptionPojoList));
    }

    /**
     * 客户跟进记录排序
     *
     * @author long.rao
     * @date 2019-03-28 20:20
     */
    public List<SelectOptionPojo> getCommunicateOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, CustomerCommunicateEnum.COMMUNICATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(CustomerCommunicateEnum.COMMUNICATE_TIME.getAttr()),
                    explainMap.get(CustomerCommunicateEnum.COMMUNICATE_TIME.getAttr()).getAttrName(), CustomerCommunicateEnum.COMMUNICATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, CustomerCommunicateEnum.UPDATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(CustomerCommunicateEnum.UPDATE_TIME.getAttr()),
                    explainMap.get(CustomerCommunicateEnum.UPDATE_TIME.getAttr()).getAttrName(), CustomerCommunicateEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 供应商跟进记录排序
     *
     * @author long.rao
     * @date 2019-03-28 20:20
     */
    public List<SelectOptionPojo> getSupplierCommunicateOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, SupplierCommunicateEnum.COMMUNICATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SupplierCommunicateEnum.COMMUNICATE_TIME.getAttr()), explainMap.get(SupplierCommunicateEnum.COMMUNICATE_TIME.getAttr()).getAttrName(), SupplierCommunicateEnum.COMMUNICATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, SupplierCommunicateEnum.UPDATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SupplierCommunicateEnum.UPDATE_TIME.getAttr()), explainMap.get(SupplierCommunicateEnum.UPDATE_TIME.getAttr()).getAttrName(), SupplierCommunicateEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 联系人排序
     * @return
     */
    public List<SelectOptionPojo> getContactOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        List<Object> value = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        value.add(ContactEnum.LEVEL.getAttr());
        if (fieldEnable(explainMap, ContactEnum.LEVEL.getAttr())) {
            attrEntity = explainMap.get(ContactEnum.LEVEL.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), ContactEnum.LEVEL.getAttr()));
        }
        List<Object> value1 = new ArrayList<>();
        value1.add(ContactEnum.IMPORTANT_DEGREE.getAttr());
        if (fieldEnable(explainMap, ContactEnum.IMPORTANT_DEGREE.getAttr())) {
            attrEntity = explainMap.get(ContactEnum.IMPORTANT_DEGREE.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, attrEntity.getAttrName(), ContactEnum.IMPORTANT_DEGREE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 销售机会排序
     * @author long.rao
     * @date 2019-03-20 13:45
     */
    public List<SelectOptionPojo> getOpportunityOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        FieldAttrEntity attrEntity;
        if (fieldEnable(explainMap, SalesOpportunityEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(SalesOpportunityEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(SalesOpportunityEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), FieldTypeEnum.ADDTIME.getAlias()));
        }
        if (fieldEnable(explainMap, SalesOpportunityEnum.UPDATE_TIME.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(SalesOpportunityEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(SalesOpportunityEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, attrEntity.getAttrName(), FieldTypeEnum.UPDATETIME.getAlias()));
        }
        if (fieldEnable(explainMap, SalesOpportunityEnum.ESTIMATE_END_TIME.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(SalesOpportunityEnum.ESTIMATE_END_TIME.getAttr());
            attrEntity = explainMap.get(SalesOpportunityEnum.ESTIMATE_END_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, attrEntity.getAttrName(), SalesOpportunityEnum.ESTIMATE_END_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 回款排序
     * @return
     */
    public List<SelectOptionPojo> getPaymentOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PaymentEnum.REAL_PAY_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaymentEnum.REAL_PAY_TIME.getAttr());
            attrEntity = explainMap.get(PaymentEnum.REAL_PAY_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaymentEnum.REAL_PAY_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PaymentEnum.REAL_AMOUNT.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(PaymentEnum.REAL_AMOUNT.getAttr());
            attrEntity = explainMap.get(PaymentEnum.REAL_AMOUNT.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, attrEntity.getAttrName(), PaymentEnum.REAL_AMOUNT.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 预收款余额排序
     * @return
     */
    public List<SelectOptionPojo> getPaymentBalanceOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PaymentBalanceEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaymentBalanceEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(PaymentBalanceEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaymentBalanceEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PaymentBalanceEnum.ADVANCE_PAYMENT_BALANCE.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaymentBalanceEnum.ADVANCE_PAYMENT_BALANCE.getAttr());
            attrEntity = explainMap.get(PaymentBalanceEnum.ADVANCE_PAYMENT_BALANCE.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaymentBalanceEnum.ADVANCE_PAYMENT_BALANCE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 获取发票排序项
     * @author long.rao
     * @date 2019-03-18 08:52
     */
    public List<SelectOptionPojo> getInvoiceOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, InvoiceEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(InvoiceEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(InvoiceEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), InvoiceEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, InvoiceEnum.TOTAL_MONEY.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(InvoiceEnum.TOTAL_MONEY.getAttr());
            attrEntity = explainMap.get(InvoiceEnum.TOTAL_MONEY.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, attrEntity.getAttrName(), InvoiceEnum.TOTAL_MONEY.getAttr()));
        }
        if (fieldEnable(explainMap, InvoiceEnum.INVOICE_DATE.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(InvoiceEnum.INVOICE_DATE.getAttr());
            attrEntity = explainMap.get(InvoiceEnum.INVOICE_DATE.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, attrEntity.getAttrName(), InvoiceEnum.INVOICE_DATE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 获取进项发票排序项
     * @author long.rao
     * @date 2019-03-18 08:52
     */
    public List<SelectOptionPojo> getPurchaseInvoiceOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PurchaseInvoiceEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PurchaseInvoiceEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(PurchaseInvoiceEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PurchaseInvoiceEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PurchaseInvoiceEnum.TOTAL_MONEY.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(PurchaseInvoiceEnum.TOTAL_MONEY.getAttr());
            attrEntity = explainMap.get(PurchaseInvoiceEnum.TOTAL_MONEY.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, attrEntity.getAttrName(), PurchaseInvoiceEnum.TOTAL_MONEY.getAttr()));
        }
        if (fieldEnable(explainMap, PurchaseInvoiceEnum.INVOICE_DATE.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(PurchaseInvoiceEnum.INVOICE_DATE.getAttr());
            attrEntity = explainMap.get(PurchaseInvoiceEnum.INVOICE_DATE.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, attrEntity.getAttrName(), PurchaseInvoiceEnum.INVOICE_DATE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 费用排序项
     * @param explainMap
     * @return
     * 创建时间 2020/4/27 5:11 PM
     * 修改时间 2020/4/27 5:11 PM
     * @author chy
     */
    public List<SelectOptionPojo> getExpenseOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ExpenseEnum.CONSUME_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(ExpenseEnum.CONSUME_TIME.getAttr());
            attrEntity = explainMap.get(ExpenseEnum.CONSUME_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), ExpenseEnum.CONSUME_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 线索排序项
     * @param explainMap
     * @return
     */
    public List<SelectOptionPojo> getClueOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ClueEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(ClueEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, explainMap.get(ClueEnum.ADD_TIME.getAttr()).getAttrName(), ClueEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, ClueEnum.UPDATE_TIME.getAttr())) {
            List<Object> value1 = new ArrayList<>();
            value1.add(ClueEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value1, explainMap.get(ClueEnum.UPDATE_TIME.getAttr()).getAttrName(), ClueEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, ClueEnum.LAST_CONNECT_TIME.getAttr())) {
            List<Object> value2 = new ArrayList<>();
            value2.add(ClueEnum.LAST_CONNECT_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value2, explainMap.get(ClueEnum.LAST_CONNECT_TIME.getAttr()).getAttrName(), ClueEnum.LAST_CONNECT_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 报销单排序项
     * @param explainMap
     * @return
     * 创建时间 2020/4/27 5:11 PM
     * 修改时间 2020/4/27 5:11 PM
     * @author chy
     */
    public List<SelectOptionPojo> getReimbursementFormOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ReimbursementFormEnum.SUBMIT_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(ReimbursementFormEnum.SUBMIT_TIME.getAttr());
            attrEntity = explainMap.get(ReimbursementFormEnum.SUBMIT_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), ReimbursementFormEnum.SUBMIT_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 回款单排序项
     *
     * @param explainMap 解释
     * @return java.util.List<com.xbongbong.pro.applist.pojo.SelectOptionPojo>
     * @author 徐俊杰
     * @date 2019/11/22 13:40
     * @since v1.0
     */
    public List<SelectOptionPojo> getPaymentSheetOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PaymentSheetEnum.PAYMENT_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaymentSheetEnum.PAYMENT_TIME.getAttr());
            attrEntity = explainMap.get(PaymentSheetEnum.PAYMENT_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaymentSheetEnum.PAYMENT_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PaymentSheetEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaymentSheetEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(PaymentSheetEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaymentSheetEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PaymentSheetEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaymentSheetEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(PaymentSheetEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaymentSheetEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 预付款余额排序
     *
     * @param explainMap 解释映射
     * @return java.util.List<com.xbongbong.pro.applist.pojo.SelectOptionPojo>
     * @author 徐俊杰
     * @date 2020/3/5 9:12
     * @since v1.0
     */
    public List<SelectOptionPojo> getPayBalanceOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PayBalanceEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PayBalanceEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(PayBalanceEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PayBalanceEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PayBalanceEnum.ADVANCE_PAY_BALANCE.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PayBalanceEnum.ADVANCE_PAY_BALANCE.getAttr());
            attrEntity = explainMap.get(PayBalanceEnum.ADVANCE_PAY_BALANCE.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PayBalanceEnum.ADVANCE_PAY_BALANCE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 付款单排序项
     *
     * @param explainMap 解释
     * @return java.util.List<com.xbongbong.pro.applist.pojo.SelectOptionPojo>
     * @author 徐俊杰
     * @date 2020/3/7 16:51
     * @since v1.0
     */
    public List<SelectOptionPojo> getPaySheetOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PaySheetEnum.REAL_PAY_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaySheetEnum.REAL_PAY_TIME.getAttr());
            attrEntity = explainMap.get(PaySheetEnum.REAL_PAY_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaySheetEnum.REAL_PAY_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PaySheetEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaySheetEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(PaySheetEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaySheetEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PaySheetEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(PaySheetEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(PaySheetEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), PaySheetEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    public List<ItemPoJo> getTimeItemPoJos(FieldAttrEntity attrEntity, String attr){
        List<ItemPoJo> itemPoJos = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        long startTime = DateTimeUtil.getTodayInt();
        long endTime = startTime + TimeConstant.SECONDS_PER_DAY;
        List<Object> value = new ArrayList<>();
        value.add(startTime);
        value.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.TODAY),value,attr));

        List<Object> value1 = new ArrayList<>();
        startTime = DateTimeUtil.getTodayInt() - TimeConstant.SECONDS_PER_DAY;
        endTime = DateTimeUtil.getTodayInt();
        value1.add(startTime);
        value1.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.YESTERDAY),value1,attr) );

        List<Object> value2 = new ArrayList<>();
        startTime = DateTimeUtil.getThisWeekMorning();
        endTime = startTime + TimeConstant.SECONDS_PER_WEEK;
        value2.add(startTime);
        value2.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.THIS_WEEK),value2,attr ) );

        List<Object> value3 = new ArrayList<>();
        startTime = DateTimeUtil.getThisWeekMorning() - TimeConstant.SECONDS_PER_WEEK;
        endTime = DateTimeUtil.getThisWeekMorning();
        value3.add(startTime);
        value3.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.LAST_WEEK),value3,attr));

        List<Object> value4 = new ArrayList<>();
        startTime = DateTimeUtil.getFirstDateOfThisMonth();
        endTime = DateTimeUtil.getLastDateOfThisMonth();
        value4.add(startTime);
        value4.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.THIS_MONTH),value4,attr ));

        List<Object> value5 = new ArrayList<>();
        startTime = DateTimeUtil.getFirstDateOfLastMonth();
        endTime = DateTimeUtil.getFirstDateOfThisMonth();
        value5.add(startTime);
        value5.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.LAST_MONTH),value5,attr ));

        List<Object> value6 = new ArrayList<>();
        startTime = DateTimeUtil.getTodayInt() - 6 * TimeConstant.SECONDS_PER_DAY;
        endTime = DateTimeUtil.getTodayInt() + TimeConstant.SECONDS_PER_DAY;
        value6.add(startTime);
        value6.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.SEVEN_DAYS),value6,attr ));


        List<Object> value7 = new ArrayList<>();
        startTime = DateTimeUtil.getTodayInt() - TimeConstant.SECONDS_THREE_MONTH + TimeConstant.SECONDS_PER_DAY;
        endTime = DateTimeUtil.getTodayInt() + TimeConstant.SECONDS_PER_DAY;
        value7.add(startTime);
        value7.add(endTime);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.THREE_MONTHS),value7,attr ));


        List<Object> value8 = new ArrayList<>();
        value3.add(StringConstant.CUSTOM);
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(StringConstant.CUSTOM_TIME),value8,attr ,FieldTypeEnum.DATETIME.getType()));

        return itemPoJos;
    }

    public List<ItemPoJo>  getStarFilter(FieldAttrEntity fieldAttrEntity) {
        List<ItemPoJo> itemPoJos = new ArrayList<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        Integer fieldType = fieldAttrEntity.getFieldType();
        String saasAttr = fieldAttrEntity.getSaasAttr();
        String attr = fieldAttrEntity.getAttr();
        itemPoJos.add(new ItemPoJo(I18nMessageUtil.getMessage(CommonConstant.LESS_THAN_ONE_STAR),0));
        for (StarEnum starEnum : StarEnum.getStarsForScreen()) {
            itemPoJos.add(new ItemPoJo(starEnum.getText(),starEnum.getValue()));
        }
        return itemPoJos;
    }

    public List<ItemPoJo>  listOfBirthday() {
        List<ItemPoJo> list = new ArrayList<>();
        list.add(new ItemPoJo(BirthdayFilterEnum.TODAY.getText(),BirthdayFilterEnum.TODAY.getValue()));
        list.add(new ItemPoJo(BirthdayFilterEnum.TOMORROW.getText(),BirthdayFilterEnum.TOMORROW.getValue()));
        list.add(new ItemPoJo(BirthdayFilterEnum.SEVEN_DAYS.getText(),BirthdayFilterEnum.SEVEN_DAYS.getValue()));
        return list;
    }

    public List<ItemPoJo>  listOfWorkOrderNodeStatus() {
        List<ItemPoJo> list = new ArrayList<>();
        list.add(new ItemPoJo(WorkOrderNodeStatusEnum.UNACCEPTED.getName(),"1"));
        list.add(new ItemPoJo(WorkOrderNodeStatusEnum.ONGOING.getName(),"2"));
        list.add(new ItemPoJo(WorkOrderNodeStatusEnum.FINISH.getName(),"3"));
        list.add(new ItemPoJo(WorkOrderNodeStatusEnum.CLOSE.getName(),"4"));
        list.add(new ItemPoJo(WorkOrderNodeStatusEnum.ROLLBACK.getName(),"5"));
        list.add(new ItemPoJo(WorkOrderNodeStatusEnum.TRANSFERRED.getName(),"6"));
        return list;
    }

    public List<ItemPoJo>  listOfWorkOrderStatus(Integer defaultGroup, Long listGroupId) {
        List<ItemPoJo> list = new ArrayList<>();
        if (Objects.equals(defaultGroup,1) && (Objects.equals(listGroupId, (long)ListGroupEnum.WORK_ORDER_RESPONSE_BY_ME.getCode()) || Objects.equals(listGroupId, (long)ListGroupEnum.WORK_ORDER_RESPONSE_BY_SUB.getCode()))){
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.UNACCEPTED.getName(),WorkOrderNodeStatusEnum.UNACCEPTED.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.ONGOING.getName(),WorkOrderNodeStatusEnum.ONGOING.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.FINISH.getName(),WorkOrderNodeStatusEnum.FINISH.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.CLOSE.getName(),WorkOrderNodeStatusEnum.CLOSE.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.ROLLBACK.getName(),WorkOrderNodeStatusEnum.ROLLBACK.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.TRANSFERRED.getName(),WorkOrderNodeStatusEnum.TRANSFERRED.getCode()));
        } else {
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.UNACCEPTED.getName(),WorkOrderNodeStatusEnum.UNACCEPTED.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.ONGOING.getName(),WorkOrderNodeStatusEnum.ONGOING.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.FINISH.getName(),WorkOrderNodeStatusEnum.FINISH.getCode()));
            list.add(new ItemPoJo(WorkOrderNodeStatusEnum.CLOSE.getName(),WorkOrderNodeStatusEnum.CLOSE.getCode()));
        }
        return list;
    }

    public List<ItemPoJo>  listOfWorkOrderTimeOut() {
        List<ItemPoJo> list = new ArrayList<>();
        list.add(new ItemPoJo(I18nMessageUtil.getMessage(I18nStringConstant.TIMED_OUT),"0"));
        list.add(new ItemPoJo(I18nMessageUtil.getMessage(I18nStringConstant.NOT_TIMED_OUT),"1"));
        return list;
    }

    public List<ItemPoJo>  listOfWorkOrderStage(Long formId, String corpid) {
        List<ItemPoJo> list = new ArrayList<>();
        WorkOrderTemplateEntity workOrderTemplateEntity = workOrderTemplateService.getByFormId(formId, corpid);
        Long templateId = workOrderTemplateEntity.getId();
        List<WorkOrderStageEntity> workOrderStageEntityList = workOrderStageService.getStageList(templateId, corpid, false);
        for (WorkOrderStageEntity entity : workOrderStageEntityList){
            ItemPoJo itemDataPoJo = new ItemPoJo();
            itemDataPoJo.setText(entity.getName());
            itemDataPoJo.setValue(entity.getId());
            list.add(itemDataPoJo);
        }
        return list;
    }

    public List<ItemPoJo>  getPublicGroupItems() {
        List<ItemPoJo> list = new ArrayList<>();
        ItemPoJo item = new ItemPoJo(I18nMessageUtil.getMessage(RangeScreenConstant.SELECT), I18nMessageUtil.getMessage(RangeScreenConstant.SELECT));
        item.setFieldType(FieldTypeEnum.PUBLIC_GROUP.getType());
        item.setIsOther(BasicConstant.ZERO);
        list.add(item);
        return list;
    }

    /**
     * 供应商默认排序字段
     *
     * @author GuoJun.HU
     * @since V1.0
     * @return JSONArray
     * @date 2019/3/25 18:48
     */
    public List<SelectOptionPojo> getSupplierOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, SupplierEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SupplierEnum.ADD_TIME.getAttr()),
                    explainMap.get(SupplierEnum.ADD_TIME.getAttr()).getAttrName(), SupplierEnum.ADD_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 采购合同排序项
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-15 16:56
     */
    public List<SelectOptionPojo> getPurchaseOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PurchaseEnum.ADD_TIME.getAttr())) {
            attrEntity = explainMap.get(PurchaseEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(PurchaseEnum.ADD_TIME.getAttr()),
                    attrEntity.getAttrName(), PurchaseEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PurchaseEnum.SIGN_TIME.getAttr())) {
            attrEntity = explainMap.get(PurchaseEnum.SIGN_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(PurchaseEnum.SIGN_TIME.getAttr()),
                    attrEntity.getAttrName(), PurchaseEnum.SIGN_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PurchaseEnum.ESTIMATE_ARRIVE_TIME.getAttr())) {
            attrEntity = explainMap.get(PurchaseEnum.ESTIMATE_ARRIVE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(PurchaseEnum.ESTIMATE_ARRIVE_TIME.getAttr()),
                    attrEntity.getAttrName(), PurchaseEnum.ESTIMATE_ARRIVE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 采购退货单排序字段
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-26 17:08
     */
    public List<SelectOptionPojo> getReturnedPurchaseOrder(Map<String, FieldAttrEntity> explainMap) {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ReturnedPurchaseEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(ReturnedPurchaseEnum.ADD_TIME.getAttr()),
                    explainMap.get(ReturnedPurchaseEnum.ADD_TIME.getAttr()).getAttrName(), ReturnedPurchaseEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, ReturnedPurchaseEnum.TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(ReturnedPurchaseEnum.TIME.getAttr()),
                    explainMap.get(ReturnedPurchaseEnum.TIME.getAttr()).getAttrName(), ReturnedPurchaseEnum.TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * bom清单排序
     *
     * @author jian.wang
     * @return JSONArray
     */
    public List<SelectOptionPojo> getBomBillOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, BomBillEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(BomBillEnum.ADD_TIME.getAttr()),
                    explainMap.get(BomBillEnum.ADD_TIME.getAttr()).getAttrName(), BomBillEnum.ADD_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 生产单排序
     * @author jian.wang
     * @return JSONArray
     */
    public List<SelectOptionPojo> getProductionOrderOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ProductionOrderEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(ProductionOrderEnum.ADD_TIME.getAttr()),
                    explainMap.get(ProductionOrderEnum.ADD_TIME.getAttr()).getAttrName(), ProductionOrderEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, ProductionOrderEnum.PLAN_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(ProductionOrderEnum.PLAN_TIME.getAttr()),
                    explainMap.get(ProductionOrderEnum.PLAN_TIME.getAttr()).getAttrName(), ProductionOrderEnum.PLAN_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 付款管理排序
     *
     * @author Lee
     * @return JSONArray
     * @time 2018-12-04 19:30
     */
    public List<SelectOptionPojo> getPayPlanOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, PayPlanEnum.ADD_TIME.getAttr())) {
            attrEntity = explainMap.get(PayPlanEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(PayPlanEnum.ADD_TIME.getAttr()),
                    attrEntity.getAttrName(), PayPlanEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, PayPlanEnum.AMOUNT.getAttr())) {
            attrEntity = explainMap.get(PayPlanEnum.AMOUNT.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(PayPlanEnum.AMOUNT.getAttr()),
                    attrEntity.getAttrName(), PayPlanEnum.AMOUNT.getAttr()));
        }
        if (fieldEnable(explainMap, PayPlanEnum.ESTIMATE_TIME.getAttr())) {
            attrEntity = explainMap.get(PayPlanEnum.ESTIMATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(PayPlanEnum.ESTIMATE_TIME.getAttr()),
                    attrEntity.getAttrName(), PayPlanEnum.ESTIMATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 装配单排序
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-28 9:22
     */
    public List<SelectOptionPojo> getAssembleOrder(Map<String, FieldAttrEntity> explainMap) {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, AssembleEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(AssembleEnum.ADD_TIME.getAttr()),
                    explainMap.get(AssembleEnum.ADD_TIME.getAttr()).getAttrName(), AssembleEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, AssembleEnum.ASSEMBLE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(AssembleEnum.ASSEMBLE_TIME.getAttr()),
                    explainMap.get(AssembleEnum.ASSEMBLE_TIME.getAttr()).getAttrName(), AssembleEnum.ASSEMBLE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 出库单排序
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-21 18:43
     */
    public List<SelectOptionPojo> getOutstockOrder(Map<String, FieldAttrEntity> explainMap) {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, OutstockEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(OutstockEnum.ADD_TIME.getAttr()),
                    explainMap.get(OutstockEnum.ADD_TIME.getAttr()).getAttrName(), OutstockEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, OutstockEnum.TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(OutstockEnum.TIME.getAttr()),
                    explainMap.get(OutstockEnum.TIME.getAttr()).getAttrName(), OutstockEnum.TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 入库单排序
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-19 14:43
     */
    public List<SelectOptionPojo> getInstockOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, InstockEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(InstockEnum.ADD_TIME.getAttr()),
                    explainMap.get(InstockEnum.ADD_TIME.getAttr()).getAttrName(), InstockEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, InstockEnum.TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(InstockEnum.TIME.getAttr()),
                    explainMap.get(InstockEnum.TIME.getAttr()).getAttrName(), InstockEnum.TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 盘点单排序
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-26 9:49
     */
    public List<SelectOptionPojo> getInventoryOrder(Map<String, FieldAttrEntity> explainMap) {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, InventoryEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(InventoryEnum.ADD_TIME.getAttr()),
                    explainMap.get(InventoryEnum.ADD_TIME.getAttr()).getAttrName(), InventoryEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, InventoryEnum.TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(InventoryEnum.TIME.getAttr()),
                    explainMap.get(InventoryEnum.TIME.getAttr()).getAttrName(), InventoryEnum.TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 调拨单排序
     *
     * @return JSONArray
     * @author 周智
     * @time 2017-12-22 16:13
     */
    public List<SelectOptionPojo> getTransferOrder(Map<String, FieldAttrEntity> explainMap) {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, TransferEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(TransferEnum.ADD_TIME.getAttr()),
                    explainMap.get(TransferEnum.ADD_TIME.getAttr()).getAttrName(), TransferEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, TransferEnum.TRANSFER_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(TransferEnum.TRANSFER_TIME.getAttr()),
                    explainMap.get(TransferEnum.TRANSFER_TIME.getAttr()).getAttrName(), TransferEnum.TRANSFER_TIME.getAttr()));
        }

        return selectOptionPojoList;
    }

    /**
     * 获取仓库默认排序
     *
     * @author GuoJun.HU
     * @since 3.32
     * @return
     * 创建时间 2018/11/22 17:03
     */
    public List<SelectOptionPojo> getWarehouseOrder(Map<String, FieldAttrEntity> explainMap) {
        ArrayList<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, WarehouseEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WarehouseEnum.ADD_TIME.getAttr()),
                    explainMap.get(WarehouseEnum.ADD_TIME.getAttr()).getAttrName(), WarehouseEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, WarehouseEnum.UPDATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WarehouseEnum.UPDATE_TIME.getAttr()),
                    explainMap.get(WarehouseEnum.UPDATE_TIME.getAttr()).getAttrName(), WarehouseEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 供应商联系人排序
     *
     * @author long.rao
     * @date 2019-03-08 14:12
     * @return JSONArray
     */
    public List<SelectOptionPojo> getSupplierContactOrder(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, SupplierContactEnum.LEVEL.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SupplierContactEnum.LEVEL.getAttr()),
                    explainMap.get(SupplierContactEnum.LEVEL.getAttr()).getAttrName(), 1, SupplierContactEnum.LEVEL.getFieldType(), 0,
                    SupplierContactEnum.LEVEL.getAttr(), null, ConditionEnum.EQUAL.getSymbol()));
        }
        return selectOptionPojoList;
    }

    /**
     * 获取产品默认排序
     *
     * @author GuoJun.HU
     * @since 3.32
     * @return
     * 创建时间 2018/11/22 17:03
     */
    public List<SelectOptionPojo> getProductOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, ProductEnum.ADD_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(ProductEnum.ADD_TIME.getAttr()),
                    explainMap.get(ProductEnum.ADD_TIME.getAttr()).getAttrName(), ProductEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, ProductEnum.UPDATE_TIME.getAttr())) {
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(ProductEnum.UPDATE_TIME.getAttr()),
                    explainMap.get(ProductEnum.UPDATE_TIME.getAttr()).getAttrName(), ProductEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * Description: 工单默认排序
     * @return com.alibaba.fastjson.JSONArray
     * @author 魏荣杰
     * @date 2019/5/5 9:59
     * @since v1.0
     */
    public List<SelectOptionPojo> getWorkOrderOrder(Map<String, FieldAttrEntity> explainMap) throws XbbException{
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, WorkOrderEnum.ADD_TIME.getAttr())) {
            attrEntity = explainMap.get(WorkOrderEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WorkOrderEnum.ADD_TIME.getAttr()), attrEntity.getAttrName(), WorkOrderEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, WorkOrderEnum.IMPLEMENTATION_TIME.getAttr())) {
            attrEntity = explainMap.get(WorkOrderEnum.IMPLEMENTATION_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WorkOrderEnum.IMPLEMENTATION_TIME.getAttr()), attrEntity.getAttrName(), WorkOrderEnum.IMPLEMENTATION_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, WorkOrderEnum.UPDATE_TIME.getAttr())) {
            attrEntity = explainMap.get(WorkOrderEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WorkOrderEnum.UPDATE_TIME.getAttr()), attrEntity.getAttrName(), WorkOrderEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, WorkOrderEnum.EMERGENCY_LEVEL.getAttr())) {
            attrEntity = explainMap.get(WorkOrderEnum.EMERGENCY_LEVEL.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(WorkOrderEnum.EMERGENCY_LEVEL.getAttr()), attrEntity.getAttrName(), WorkOrderEnum.EMERGENCY_LEVEL.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * Description: 退货退款默认排序
     * @return com.alibaba.fastjson.JSONArray
     * @author long.rao
     * @date 2019-05-18 17:05
     */
    public List<SelectOptionPojo> getRefundOrder(){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        return selectOptionPojoList;
    }

    /**
     * 获取字段是否可用（isOpen,visiable都为1才可用）
     *
     * @param explainMap
     * @param attr
     * @return
     */
    private boolean fieldEnable(Map<String, FieldAttrEntity> explainMap, String attr) {
        boolean enable = false;
        if (explainMap.containsKey(attr)) {
            FieldAttrEntity entity = explainMap.get(attr);
            if (Objects.equals(entity.getIsOpen(), 1) && Objects.equals(entity.getVisible(), 1)) {
                enable = true;
            }
        }
        return enable;
    }

    public List<SelectOptionPojo> getGuaranteeSearchOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        // 批次
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SelectProductEnum.BATCH.getSaasAttr()),
                SelectProductEnum.BATCH.getAttrName(), SelectProductEnum.BATCH.getSaasAttr()));
        // 生产日期
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SelectProductEnum.PRODUCE_DATE.getSaasAttr()),
                SelectProductEnum.PRODUCE_DATE.getAttrName(), SelectProductEnum.PRODUCE_DATE.getSaasAttr()));
        // 到期日期
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SelectProductEnum.EXPIRE_DATE.getSaasAttr()),
                SelectProductEnum.EXPIRE_DATE.getAttrName(), SelectProductEnum.EXPIRE_DATE.getSaasAttr()));
        // 库存数量
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SelectProductEnum.STOCK.getSaasAttr()),
                SelectProductEnum.STOCK.getAttrName(), SelectProductEnum.STOCK.getSaasAttr()));
        // 成本小计
        selectOptionPojoList.add(new SelectOptionPojo(Collections.singletonList(SelectProductEnum.TOTAL_COST.getSaasAttr()),
                SelectProductEnum.TOTAL_COST.getAttrName(), SelectProductEnum.TOTAL_COST.getSaasAttr()));
        return selectOptionPojoList;
    }

    /**
     * 经销商账号排序
     *
     * @param explainMap 解释映射
     * @return java.util.List<com.xbongbong.pro.applist.pojo.SelectOptionPojo>
     * @author lee
     * @date 2021/3/5 9:12
     * @since v1.0
     */
    public List<SelectOptionPojo> getAccountSearchFilter(Map<String, FieldAttrEntity> explainMap){
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, DistributorAccountEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(DistributorAccountEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(DistributorAccountEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), DistributorAccountEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, DistributorAccountEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(DistributorAccountEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(DistributorAccountEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), DistributorAccountEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, DistributorAccountEnum.NAME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(DistributorAccountEnum.NAME.getAttr());
            attrEntity = explainMap.get(DistributorAccountEnum.NAME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), DistributorAccountEnum.NAME.getAttr()));
        }
        if (fieldEnable(explainMap, DistributorAccountEnum.PHONE.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(DistributorAccountEnum.PHONE.getAttr());
            attrEntity = explainMap.get(DistributorAccountEnum.PHONE.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), DistributorAccountEnum.PHONE.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 其他收入单需排序字段
     * @param explainMap
     * @return java.util.List<com.xbongbong.pro.applist.pojo.SelectOptionPojo>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public List<SelectOptionPojo> getOtherIncomeOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, OtherIncomeEnum.INCOME_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(OtherIncomeEnum.INCOME_TIME.getAttr());
            attrEntity = explainMap.get(OtherIncomeEnum.INCOME_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), OtherIncomeEnum.INCOME_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, OtherIncomeEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(OtherIncomeEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(OtherIncomeEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), OtherIncomeEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, OtherIncomeEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(OtherIncomeEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(OtherIncomeEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), OtherIncomeEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }
    /**
     * 其他支出单需排序字段
     * @param explainMap
     * @return java.util.List<com.xbongbong.pro.applist.pojo.SelectOptionPojo>
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    public List<SelectOptionPojo> getOtherExpenseOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, OtherExpenseEnum.EXPENSE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(OtherExpenseEnum.EXPENSE_TIME.getAttr());
            attrEntity = explainMap.get(OtherExpenseEnum.EXPENSE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), OtherExpenseEnum.EXPENSE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, OtherExpenseEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(OtherExpenseEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(OtherExpenseEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), OtherExpenseEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, OtherExpenseEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(OtherExpenseEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(OtherExpenseEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), OtherExpenseEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }
    /**
     * 获取调拨单需要排序字段
     *
     * @param explainMap
     * @return
     */
    public List<SelectOptionPojo> getFundTransferOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, FundTransferEnum.TRANSFER_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(FundTransferEnum.TRANSFER_TIME.getAttr());
            attrEntity = explainMap.get(FundTransferEnum.TRANSFER_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), FundTransferEnum.TRANSFER_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, FundTransferEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(FundTransferEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(FundTransferEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), FundTransferEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, FundTransferEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(FundTransferEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(FundTransferEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), FundTransferEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 智能补货需要排序字段
     * @param explainMap
     * @return
     */
    public List<SelectOptionPojo> getSmartReplenishmentOrder(Map<String, FieldAttrEntity> explainMap) {
        List<FieldAttrEntity> fieldAttrEntityList = new ArrayList<>();
        FieldAttrEntity addTimeAttrEntity = explainMap.get(ContractEnum.ADD_TIME.getAttr());
        FieldAttrEntity updateTimeAttrEntity = explainMap.get(ContractEnum.UPDATE_TIME.getAttr());
        fieldAttrEntityList.add(addTimeAttrEntity);
        fieldAttrEntityList.add(updateTimeAttrEntity);
        explainMap.clear();
        formDataListSearchHelp.handleSmartReplenishmentExplain(fieldAttrEntityList);
        if (CollectionUtils.isNotEmpty(fieldAttrEntityList)){
            fieldAttrEntityList.forEach(item ->{
                explainMap.put(item.getAttr(),item);
            });
        }
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, FundTransferEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(FundTransferEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(FundTransferEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), FundTransferEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, FundTransferEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(FundTransferEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(FundTransferEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), FundTransferEnum.UPDATE_TIME.getAttr()));
        }
        return selectOptionPojoList;
    }

    /**
     * 获取知识条目需要排序字段
     *
     * @param explainMap
     * @return
     */
    public List<SelectOptionPojo> getKnowledgeOrder(Map<String, FieldAttrEntity> explainMap) {
        List<SelectOptionPojo> selectOptionPojoList = new ArrayList<>();
        FieldAttrEntity attrEntity;
        selectOptionPojoList.add(new SelectOptionPojo(new ArrayList<>(), I18nMessageUtil.getMessage(StringConstant.DEFAULT_SORT_TAG), null));
        if (fieldEnable(explainMap, KnowledgeDataEnum.UPDATE_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(KnowledgeDataEnum.UPDATE_TIME.getAttr());
            attrEntity = explainMap.get(KnowledgeDataEnum.UPDATE_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(),KnowledgeDataEnum.UPDATE_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, KnowledgeDataEnum.ADD_TIME.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(KnowledgeDataEnum.ADD_TIME.getAttr());
            attrEntity = explainMap.get(KnowledgeDataEnum.ADD_TIME.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), KnowledgeDataEnum.ADD_TIME.getAttr()));
        }
        if (fieldEnable(explainMap, KnowledgeDataEnum.USAGE_COUNT.getAttr())) {
            List<Object> value = new ArrayList<>();
            value.add(KnowledgeDataEnum.USAGE_COUNT.getAttr());
            attrEntity = explainMap.get(KnowledgeDataEnum.USAGE_COUNT.getAttr());
            selectOptionPojoList.add(new SelectOptionPojo(value, attrEntity.getAttrName(), KnowledgeDataEnum.USAGE_COUNT.getAttr()));
        }
        return selectOptionPojoList;
    }
}
